<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page contentType="text/html; charset=UTF-8" import="user.*, java.util.*, java.sql.*" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Customer_page</title>
<style type="text/css">
<!--
.STYLE1 {
	font-size: large;
	font-style: italic;
	font-weight: bold;
}
.STYLE2 {color: #0000FF}
-->
</style>
</head>

<BODY leftMargin=0 topMargin=0>

<% 
String SubmitMessage = request.getParameter("SubmitMessage");
if (SubmitMessage != null && SubmitMessage.length() > 0)
{
	String name = request.getParameter("name"); 
	String mail = request.getParameter("mail"); 
	String title = request.getParameter("title"); 
	String content = request.getParameter("content"); 
	if(name==null) 
		name=""; 
	if(title==null) 
		title=""; 
	if(content==null) 
		content=""; 
	if(mail==null) 
		mail=""; 
	if(name.length()==0) 
		out.println("<script>alert(unescape('Please input your name!'))</script>"); 
	else if(title.length()==0) 
		out.println("<script>alert(unescape('Please input the title!'))</script>"); 
	else if(content.length()==0) 
		out.println("<script>alert(unescape('Please input your message!'))</script>"); 
	else 
	{ 
		java.util.Date date = new java.util.Date(); 
		String datetime = new Timestamp(date.getTime()).toString(); 
		
		try 
		{ 
			DBConnector db = DBConnector.getDBConnector();
			String InsertMessage = "insert into message values(null, '";			
			InsertMessage += title + "','" + name + "',";			 
			if(mail.length()==0) 
				InsertMessage += "null"; 
			else InsertMessage += "'" + mail + "'"; 
			InsertMessage += ",'" + datetime + "','" + content + "')";		

			try 
			{ 
				db.prepareStatement(InsertMessage);
				db.updatePstmt(); 
				out.println("<script>alert(unescape('your message has been recorded. Thanks.'))</script>");
				
			} catch(Exception e) {
				// TODO Exception handling
			}
		}finally {
				// TODO Final handling
		}				
	
	} 
}
%> 

<TABLE cellSpacing=0 cellPadding=0 width=810 align=center border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width="24%"><A href="index.jsp"><IMG 
      height=118 src="Pics/restaurantLogo.JPG" width=242 
      border=0></A></TD>
    <td valign="top"><br></td><TD width="76%">
    <% if (session.getAttribute("isLogedIn").toString().equals("true")) {%>
    		<p align="left">Hello, <%= session.getAttribute("username") %>, Welcome to Lumen!</p>
    <% } %>
	<form action="./servlet/FoodSearching" method="post">
	<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">          
		  <tr> 		  	
            <td>				 
			 <div align="center"> 
                <select name="select_restaurant" onChange="changelocation(document.frmLink.L_CityID.options[document.frmLink.L_CityID.selectedIndex].value)" style="width:80px">
                  <option value="0">Any</option>
                  <!-- 3/11 -->
                  <%= DisplayRestaurantPage.getRestaurantListItems() %>
				  
                </select>
			  </div>			  
			  </td>
            <td align="center"><input name="price_search" type="text" class="input" id="keyword" size="30" value="search for prices" onMouseDown="this.value=''"></td>
            
			<td align="center"><input name="keyword_search" type="text" class="input" id="keyword" size="30" value="search for keywords" onMouseDown="this.value=''"></td>
			<td width="63" align="center"><input name="search_button" type="submit" id="button1" value="Search"></td>
          </tr>	  
        </table>
		</form>
		
		
      </TD>
  </TR></TBODY></TABLE>

<BR>
<TABLE cellSpacing=0 cellPadding=0 width=778 align=center border=0>
  <TBODY>
  
  <TR>
   
    <TD align="center">
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD align="center" width="28%">
            
            <TABLE cellSpacing=1 cellPadding=0 bgColor=#ffffff border=0>
              <TBODY>
              <TR>
                <TD>              
                <%= DisplayRestaurantPage.getRestaurantLogo() %>
				</TD>  
              </TR></TBODY></TABLE>            
              
              
            <TABLE height=8 cellSpacing=0 cellPadding=0 width=90 align=center 
            border=0>
              <TBODY>
              <TR>
                
              </TR></TBODY></TABLE></TD>
          <TD vAlign=top align="center" width="72%">
            <TABLE cellSpacing=0 cellPadding=0 width=551 bgColor=#ffffff 
            border=0>
              <TBODY>
              <TR>
                
                <TD vAlign=top rowSpan=3>
                  <TABLE cellSpacing=0 cellPadding=8 width="95%" border=0>
                    <TBODY>
                    <TR>
                      <TD align="center"><FONT color=#000000>welcome to <%=DisplayRestaurantPage.getRestaurantName()%></FONT></TD>
                    </TR></TBODY></TABLE>
                  <TABLE height=90 cellSpacing=0 cellPadding=3 width="95%" 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD align=right width="34%" height=14><FONT 
                        color=#000000>Tel :</FONT></TD>
                      <TD align=left width="66%"> <FONT color=#ff0000 
                        size=3>						
                         <%= DisplayRestaurantPage.getRestaurantPhoneNum() %>					 
                      </FONT></TD>
                    </TR>
					<TR>
                    	<TD align=right height=14><FONT 
                        color=#000000>Address :</FONT></TD>
                      <TD align=left><font color="#000000">					  	
					  	<%= DisplayRestaurantPage.getRestaurantAddress() %>					  	
						</font></TD>
                    </TR>
                    
                    <TR>
                      <TD align=right height=14><FONT 
                        color=#000000>Opening Hours :</FONT><BR></TD>
                      <TD align=left><FONT 
                        color=#000000>
						<%=DisplayRestaurantPage.getRestaurantOpenCloseTime()%>
						</FONT></TD></TR>
                    	<TR>
                      <TD align=right height=14><FONT 
                        color=#000000>Delivery Hours :</FONT><BR></TD>
                      <TD align=left><FONT 
                        color=#000000>
						<%=DisplayRestaurantPage.getRestaurantOpenCloseTime()%>
						</FONT></TD></TR>
                    
                    
                    <TR>
                      <TD align=right height=14><FONT 
                        color=#000000>Rating :</FONT></TD>
                      <TD align=left><FONT 
                    color=#ff0000>						
						<label id='Mcdonalds_rating'>
					  	</label>
						</FONT></TD></TR>
                    
                    </TABLE></TD>
                
              </TR>
                </TABLE></TD></TR></TABLE></TD>
  <TR>
    
  </TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=0 width=785 align=center border=0>
  <TBODY>
  <TR>
    <TD vAlign=top height=354>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
        <TBODY>
        <TR>
          <TD vAlign=top width="24%"><TABLE height="462" cellSpacing=0 cellPadding=0 align=center 
            border=0 width="229">
              <TBODY>
              <TR><TD align = "center">
              <a href = "customer_account.jsp">Customer</a><br><br>
              <a href = "administrator_account.jsp">Administrator</a><br><br>
              <a href = "restaurant_account.jsp">Restaurant</a><br><br>
              
              <table bgColor=#929292 border = 0.5>
              <tr><td>shopping cart:</td></tr>
              <tr><td align = left>   
              	<% 
              		String username = null;
              		if(session.getAttribute("username") != null)              		          		
              			username = session.getAttribute("username").toString(); %>                                          
                <%= DisplayShoppingCart.getOrderedFoodInfo(username) %>   
                </td></tr>
                </table>   
                
                <FORM ACTION="customer_page.jsp"> 
				<TABLE align="center" border=1 cellspacing="0" cellpadding="0" bgColor=#929292> 
				<tr><td colspan = 2 align = "center">Leave Message</td></tr>				
				<tr><TD bgcolor="#cccccc"><input type="text" name="name" size=15 value = "Your Name" onMouseDown="this.value=''"></TD> 
				</TR> 				
				<tr><TD bgcolor="#cccccc"><input type="text" name="mail" size=15 value = "Your Email" onMouseDown="this.value=''"></TD> 
				</TR>
				<tr><TD bgcolor="#cccccc"><input type="text" name="title" size=15  value = "Message Title" onMouseDown="this.value=''"></TD> 
				</TR> 
				
				<tr><TD><textarea name="content" rows=7 cols=12></textarea></TD> 
				</TR> 
				<TR> 
				<TD colspan=3><TABLE align="center" width="100%" cellspacing="0" cellpadding="0"> 
				<TR> 
				<TD align="center" bgcolor="#cccccc"><input type="submit" value="submit" name = "SubmitMessage"></TD> 
				
				<TD align="center" bgcolor="#cccccc"><input type="reset" value="Reset"></TD> 
				</TR> 
				</TABLE></TD> 
				</TR> 
				
				</TABLE></FORM>           
                </TD>
                <TD></TD></TR></TBODY></TABLE>
            

          <TD vAlign=top width="76%">
            <TABLE cellSpacing=1 cellPadding=0 width="100%" align=center 
            bgColor=#929292 border=0>
           </TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 bgColor=#929292>
              <TBODY>
              <TR>
                <TD>
					<a href="checkout.jsp">Check Out Now!</a>				</TD>
              </TR></TBODY></TABLE>
            <TABLE cellSpacing=1 cellPadding=0 width="100%" align=center 
            bgColor=#929292 border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD bgColor=#eeeeee height=24><FONT 
                        color=#000000><STRONG>Available items: </STRONG></FONT></TD>
                    </TR></TBODY></TABLE></TD></TR></TBODY></TABLE>           
						  
                          <%= DisplayFoodPage.getFoodInfo() %>
                          
            <TABLE cellSpacing=1 cellPadding=0 width="100%" align=center 
            bgColor=#929292 border=0>              
              
              <TBODY>
              <TR>
                <TD>
					<a href="checkout.jsp">Check Out Now! 
				    </a></TD>
              </TR></TBODY></TABLE>
                
            </TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
            </BODY></HTML>          



            
